<template>
	<view :id="success ? 'appbw' : 'app'">


		<!-- 提现金额 -->
		<uni-transition :mode-class="['fade']" :show="!success">

			<view class="mt30 mlr30 ptb30 plr30 bw br10 f30">
				<view class="c333 f30">提现金额（元）</view>
				<view class="mt30 df aic f32">
					<text class="f54">￥</text>
					<input type="number" v-model="money" :placeholder="'可提现 '+ userinfo.money +' 元'"
						placeholder-class="caaa" class="pt10" v-if="type == 1" />
					<input type="number" v-model="money" :placeholder="'可提现 '+ userinfo.balance +' 元'"
						placeholder-class="caaa" class="pt10" v-if="type == 2" />
				</view>
			</view>

			<view class="w80p mauto c333 f28 lh100">提现手续费{{config.cash_rate}}%</view>

			<view class="mlr30 btn pay f34 br10 fwb" @click="confirm">提现</view>
		</uni-transition>


		<uni-transition class="pf t0 w100p" :modeClass="['fade']" :show="success">
			<!-- 结果 -->
			<view class="result df dfc aic mt10p">
				<!-- 图 -->
				<view class="img wh160">
					<image src="/static/success.png" mode="aspectFit"></image>
				</view>

				<!-- 文字 -->
				<view class="txt mt60 c333 f34 tac fwb">
					<view>下单成功提现审核提交成功</view>
					<view class="mt30">请等待后台审核</view>
				</view>

				<!-- 操作框 -->
				<view class="fnArea df aic mt70">
					<navigator delta="1" open-type="navigateBack" class="btn prmary w250 ml30" hover-class="none">我知道了
					</navigator>
				</view>
			</view>
		</uni-transition>
	</view>
</template>
<script>
	// 定义全局变量
	var that;
	// 默认
	export default {
		// 定义页面变量
		data() {
			return {
				// 建立页面参数
				param: {
					price: '1100',
				},
				// 建立页面变量
				pages: {},
				// 建立页面数据
				info: {},
				// 提交
				success: false,
				userinfo: {
					money: "",
					balance: ""
				},
				type: 1,
				money: "",
				config: {},
				status: ''
			}
		},


		// 获取后
		onLoad(e) {
			that = this;
			console.log(e.status);
			that.status = e.status
			that.type = e.type ? e.type : 1;
			that.config = uni.getStorageSync("config");
		},


		// 显示后
		onShow() {

			that.util.getuserinfo((rs) => {
				that.userinfo = rs.data.userinfo;
			});

		},


		// 方法列表
		methods: {

			// 确认
			confirm() {

				that.request({
					url: that.status == 1 ? '/api/cash/create' : '/api/cash/shopcreate',
					data: {
						money: that.money,
						type: that.type,
					},
					load: true,
					success(rs) {
						console.log('返回数据', rs.data)
						if (rs.code == 1) {
							// 赋值反选
							that.success = true;
							// 更改标题
							uni.setNavigationBarTitle({
								title: '提现审核',
							});
						} else {
							that.alert(rs.msg);
						}
					}
				})

			},
		},
	}
</script>
<style>


</style>
